﻿function TreeBtnSel(s, e) {
    var focusedkey = TreeListSel.focusedKey;

    TreeListSel.GetNodeValues(focusedkey, "ListName", function (data) {
        eval("parent." + parent.dialogSel.targetID + ".SetText('" + data + "')");
        parent.dialogSel.Hide();
    });
    e.processOnServer = false;
}
function GridBtnSel(s, e) {
    var field = "ListName";
    if ($("#hfIsDataObject").val() == "1") {
        //iFrameGrid.DialogGrid.GetSelectedKeysOnPage()[0]
        field = $("#hfCallBackField").val();
    }
    //iFrameGrid.DialogGrid.GetRow(14);
    iFrameGrid.DialogGrid.GetSelectedFieldValues(field, function (values) {
        var dialogID = self.frameElement.parentElement.id.split('_')[0];
        var targetID = eval("parent.parent." + dialogID + ".targetID");
        var value = values[0];

        if ($("#hfIsDataObject").val() == "1") {
            var fields = field.split(';')
            for (var f = 0; f < fields.length; f++) {
                //parent.iframeContent.iframeDataObject2.$("input[id*='Field_NewSalesNO']").val("0008")
                var newF = "input[id*='Field_" + fields[f] + "']";
                var strEval = "parent." + targetID.substring(0, targetID.lastIndexOf(".")) + ".$(\"" + newF + "\").val('" + value[f] + "')";
                eval(strEval);
                var x = "sa";
            }
        } else {

            try {
                eval("parent." + targetID + ".SetText('" + value + "')");
            } catch (e) {
                //0是iframeID，1是控件ID
                var tarages = targetID.split(".");
                eval("parent.$('#" + tarages[0] + "')[0].contentWindow." + tarages[1] + ".SetText('" + value + "')");
            }
        }
        eval("parent." + dialogID + ".Hide()");
    });
    e.processOnServer = false;
}

function GridBtnSearch(s, e) {
    parent.parent.aspxLoadpanel.SetText("正在查询，请稍候。");
    parent.parent.aspxLoadpanel.Show();
    var query = GetParamValue();
    if ($("#hfIsDataObject").val() == "1") {
        query += "&IsDataObject=1";
    }
    $("#iFrameGrid").attr("src", "DialogGridPage.aspx" + query);
    e.processOnServer = false;
}

function BtnCancel(s, e) {
    var dialogID = self.frameElement.parentElement.id.split('_')[0];
    eval("parent." + dialogID + ".Hide()");
    e.processOnServer = false;
}
